package com.dalamao.example.netty;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import java.io.IOException;
import java.net.Socket;

public class MainActivity extends AppCompatActivity {


    private TextView request;


    public static final String host= "192.168.100.103";
    int port = 60000;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        request = (TextView) findViewById(R.id.request);


        request.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                new Thread(new Runnable() {
//                    @Override
//                    public void run() {
//                        connect();
//                    }
//                }).start();





                new TimeClient().connect(host,port);








            }
        });


    }





    private void connect() {


        try {
            Socket socket = new Socket("192.168.100.103", 60000);


            Log.i("zl", "connect is success...  ");

        } catch (IOException e) {

            e.printStackTrace();
            Log.i("zl", "connect failed...  ");
        } catch (Exception e) {

            Log.i("zl", "connect Exception...  ");
            e.printStackTrace();
        }


    }
}
